<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>普通用户界面</title>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <style>
    body { font-family: sans-serif; padding: 40px; display: none; } /* 默认隐藏页面 */
    h1 { color: #333; }
  </style>
</head>
<body>
<h1>欢迎，普通用户！</h1>
<p>您进入的是普通用户界面。</p>

<script>
  // 加载后校验 token 和角色
  (async function(){
    const token = localStorage.getItem('token');

    if (!token) {
      window.location.replace('http://139.196.141.180/login');
      return;
    }

    try {
      const res = await axios.get('http://139.196.141.180/backend/auth/check', {
        headers: {
          'Authorization': token
        }
      });

      if (res.data.code !== 0 || res.data.role !== 'normal') {
        window.location.replace('http://139.196.141.180/login');
      } else {
        document.body.style.display = 'block';  // 显示页面
      }
    } catch (err) {
      window.location.replace('http://139.196.141.180/login');
    }
  })();
</script>
</body>
</html>
